<template>
  <el-row type="flex" style="width: 100%">
    <el-col :span="20">{{ treeNode.name }}</el-col>
    <el-col :span="4">
      <el-row type="flex">
        <el-col>{{ treeNode.manager }}</el-col>
        <el-col>
          <el-dropdown @command="handleCommand">
            <span class="el-dropdown-link">
              操作<i class="el-icon-arrow-down el-icon--right" />
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="add" :disabled="mixinPermission('POINT-USER-ADD-departments')">添加子部门</el-dropdown-item>
              <el-dropdown-item v-if="!isRoot" command="set" :disabled="mixinPermission('POINT-USER-UPDATE-departments')">编辑部门</el-dropdown-item>
              <el-dropdown-item v-if="!isRoot" command="remove" :disabled="mixinPermission('POINT-USER-DELETE-departments')">删除部门</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-col>
      </el-row>
    </el-col>
  </el-row>
</template>

<script>
export default {
  name: 'TreeTools',
  props: {
    treeNode: {
      type: Object,
      required: true
    },
    isRoot: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    handleCommand(command) {
      this.$emit('handle-command', command, this.treeNode.id)
    }
  }
}
</script>

<style>

</style>
